<template>
	
	<view :style="{'padding-bottom': curIndex==1?'0':'200rpx'}">
		<!-- //wangk 2022-03-03 update -->
		<shopIndex @checkClass="toClassify" v-show="curIndex==0" :menuList="menuList"></shopIndex>
		<classify ref="classify" v-show="curIndex==1" :menuList="menuList"></classify>
		<shopCar ref="shopCar" v-show="curIndex==2"></shopCar>
		<myInfo v-show="curIndex==3"></myInfo>
		
		<view class="tabbar">
			<view @click="toPath(index)" v-for="(item,index) in list" :key="index">
				<image :src="'../../static/icon/shop_'+ (curIndex==index?item.imageUrl+'_pink':item.imageUrl) +'.png'" mode=""></image>
				<view :style="{'color': curIndex==index?'#54beae':'' }">
					{{item.name}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				curIndex:-1,
				menuList:[],
				list:[
					{
						imageUrl:'home',
						name:'首页',
					},
					{
						imageUrl:'class',
						name:'分类',
					},
					{
						imageUrl:'car',
						name:'购物车',
					},
					{
						imageUrl:'user',
						name:'我的',
					}
				]
			}
		},
		onLoad(e) {
			//wangk 2022-03-03 update
			uni.setStorageSync('tenantId',uni.getStorageSync('info').tenantId)
			//伊源商城 8E17E4C0-7057-41C1-A794-842B8F624B29
			 // uni.setStorageSync('tenantId','8E17E4C0-7057-41C1-A794-842B8F624B29')
			
			 // uni.setStorageSync('tenantId','B10E96A8-2EDD-456C-A57F-A8EA9ACA1624')
			// uni.setStorageSync('info',{organizationPhone:'123456'})
			
			if(e.index){
				this.curIndex = e.index
			}else{
				this.curIndex = 0
			}
			this.getMenuList()
		},
		onShow() {
			// wangk 2022-03-03 update
			if(this.curIndex == 2){
				this.$refs.shopCar.getList()
			}
		},
		methods: {
			getMenuList(){
				this.$http('/common/api/commonData/getProductTypeList',{
					 "condition":{
					    "isRoot":true,
							"productTypeFlag":"2",
							//wangk update 2022-0721 
					    }
				},res=>{
					this.menuList = res.data.items
					this.$nextTick(()=>{
						this.$refs.classify.changeIndex(0)
					})
				})
			},
			toClassify(index){
				this.$refs.classify.changeIndex(index)
				this.curIndex = 1
			},
			toPath(index){
				if(this.curIndex == index) return;
				if(index==2){
					this.$refs.shopCar.getList()
				}
				this.curIndex = index
			}
			
		}
	}
</script>

<style scoped lang="less">
.tabbar{
	width: 100%;
	position: fixed;
	bottom: 0;
	background-color: #FFFFFF;
	border-top: 1px solid #ccc;
	z-index: 1;
	height: 120upx;
	display: flex;
	>view{
		width: 25%;
		text-align: center;
		font-size: 24upx;
		height: 100%;
		box-sizing: border-box;
		padding-top: 20upx;
		color: #333;
		>image{
			width: 54upx;
			height: 54upx;
		}
	}
}
</style>
